Add 'GPS_Diag' function to sensibly log data to/from serial port.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 15 Nov 2002 06:08:52 +0000 (06:08 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 15 Nov 2002 06:08:52 +0000 (06:08 +0000)
gpsbabel/jeeps/gpssend.c
gpsbabel/jeeps/gpsutil.c

index 372a5dfe9d72b1ef3f2081998c087a156e70b8c0..c33149d7e9f5338dfab5a3a5903f3d8ac4cddb3a 100644 (file)
@@ -92,7 +92,14 @@ void GPS_Make_Packet(GPS_PPacket *packet, UC type, UC *data, int16 n)
 }
 
 
-
+void
+Diag(void *buf, size_t sz)
+{
+       unsigned char *cbuf = (unsigned char *) buf;
+       while (sz--) {
+               GPS_Diag("%02x ", *cbuf++);
+       }
+}
 
 /* @func GPS_Write_Packet ***********************************************
 **
@@ -107,7 +114,9 @@ void GPS_Make_Packet(GPS_PPacket *packet, UC type, UC *data, int16 n)
 int32 GPS_Write_Packet(int32 fd, GPS_PPacket packet)
 {
     size_t ret;
-    
+
+    GPS_Diag("\nTx Data:");
+    Diag(&packet->dle, 3);    
     if((ret=GPS_Serial_Write(fd,(const void *)&packet->dle,(size_t)3)) == -1)
     {
        perror("write");
@@ -120,6 +129,7 @@ int32 GPS_Write_Packet(int32 fd, GPS_PPacket packet)
        return 0;
     }
 
+    Diag(packet->data, packet->bytes);
     if((ret=GPS_Serial_Write(fd,(const void *)packet->data,(size_t)packet->bytes)) == -1)
     {
        perror("write");
@@ -133,6 +143,7 @@ int32 GPS_Write_Packet(int32 fd, GPS_PPacket packet)
     }
 
 
+    Diag(&packet->chk, 3);
     if((ret=GPS_Serial_Write(fd,(const void *)&packet->chk,(size_t)3)) == -1)
     {
        perror("write");
index 662fdb42cefb0a75a3ce1c411f0c7652824ea602..8015faf1f5ad715625cca3fbe620b10e0a1d36fb 100644 (file)
@@ -23,6 +23,7 @@
 ********************************************************************/
 #include "gps.h"
 #include <fcntl.h>
+#include <stdarg.h>
 
 static int32 gps_endian_called=0;
 static int32 GPS_Little=0;
@@ -647,7 +648,18 @@ void GPS_Diagnose(int32 c)
     return;
 }
 
+void GPS_Diag(const char *fmt, ...)
+{
+    va_list argp;
+    va_start(argp, fmt);
 
+    if(gps_show_bytes) {
+         vfprintf(stdout, fmt, argp);
+    }
+    va_end(argp);
+    return;
+
+}
 
 /* @func GPS_Enable_Diagnose ***********************************************
 **